﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Classic" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2006" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
    x:Class="VMuktiGrid.Buddy.ctlBuddyList" Background="Blue"
    Height="Auto" HorizontalAlignment="Stretch">
    
	<UserControl.Resources>
		<Style x:Key="ComboBoxFocusVisual">
			<Setter Property="Control.Template">
				<Setter.Value>
					<ControlTemplate>
						<Rectangle SnapsToDevicePixels="true" Stroke="Black" StrokeDashArray="1 2" StrokeThickness="1" Margin="4,4,21,4"/>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		<Geometry x:Key="DownArrowGeometry">M 0 0 L 3.5 4 L 7 0 Z</Geometry>
		<Style x:Key="ComboBoxTransparentButtonStyle" TargetType="{x:Type ToggleButton}">
			<Setter Property="MinWidth" Value="0"/>
			<Setter Property="MinHeight" Value="0"/>
			<Setter Property="Width" Value="Auto"/>
			<Setter Property="Height" Value="Auto"/>
			<Setter Property="Background" Value="Transparent"/>
			<Setter Property="BorderBrush" Value="{x:Static Microsoft_Windows_Themes:ClassicBorderDecorator.ClassicBorderBrush}"/>
			<Setter Property="BorderThickness" Value="2"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type ToggleButton}">
						<DockPanel SnapsToDevicePixels="true" Background="{TemplateBinding Background}" LastChildFill="false">
							<Microsoft_Windows_Themes:ClassicBorderDecorator x:Name="Border" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" DockPanel.Dock="Right" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" BorderBrush="{TemplateBinding BorderBrush}" BorderStyle="AltRaised" BorderThickness="{TemplateBinding BorderThickness}">
								<Path Fill="{TemplateBinding Foreground}" HorizontalAlignment="Center" VerticalAlignment="Center" Data="{StaticResource DownArrowGeometry}"/>
							</Microsoft_Windows_Themes:ClassicBorderDecorator>
						</DockPanel>
						<ControlTemplate.Triggers>
							<Trigger Property="IsChecked" Value="true">
								<Setter Property="BorderStyle" TargetName="Border" Value="AltPressed"/>
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
			<Style.Triggers>
				<Trigger Property="IsEnabled" Value="false">
					<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}"/>
				</Trigger>
			</Style.Triggers>
		</Style>
		<Style x:Key="ComboBoxEditableTextBox" TargetType="{x:Type TextBox}">
			<Setter Property="OverridesDefaultStyle" Value="true"/>
			<Setter Property="AllowDrop" Value="true"/>
			<Setter Property="MinWidth" Value="0"/>
			<Setter Property="MinHeight" Value="0"/>
			<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type TextBox}">
						<ScrollViewer Focusable="false" x:Name="PART_ContentHost" Background="Transparent" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		<ControlTemplate x:Key="ComboBoxEditableTemplate" TargetType="{x:Type ComboBox}">
			<Border SnapsToDevicePixels="true" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
				<Grid>
					<Microsoft_Windows_Themes:ClassicBorderDecorator x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{x:Static Microsoft_Windows_Themes:ClassicBorderDecorator.ClassicBorderBrush}" BorderStyle="Sunken" BorderThickness="2">
						<Popup Focusable="False" AllowsTransparency="true" IsOpen="{TemplateBinding IsDropDownOpen}" Placement="Bottom" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" x:Name="PART_Popup">
							<Microsoft_Windows_Themes:SystemDropShadowChrome MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding Path=ActualWidth, ElementName=Border}" x:Name="Shdw" Color="Transparent">
								<Border x:Name="DropDownBorder" Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" BorderThickness="1">
									<ScrollViewer>
										<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" KeyboardNavigation.DirectionalNavigation="Contained"/>
									</ScrollViewer>
								</Border>
							</Microsoft_Windows_Themes:SystemDropShadowChrome>
						</Popup>
					</Microsoft_Windows_Themes:ClassicBorderDecorator>
					<ToggleButton Focusable="false" Margin="2" MinHeight="0" MinWidth="0" Style="{StaticResource ComboBoxTransparentButtonStyle}" Width="Auto" ClickMode="Press" IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"/>
					<DockPanel Margin="2">
						<FrameworkElement Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" DockPanel.Dock="Right"/>
						<TextBox Margin="{TemplateBinding Padding}" x:Name="PART_EditableTextBox" Style="{StaticResource ComboBoxEditableTextBox}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" IsReadOnly="{Binding Path=IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}"/>
					</DockPanel>
				</Grid>
			</Border>
			<ControlTemplate.Triggers>
				<Trigger Property="HasItems" Value="false">
					<Setter Property="MinHeight" TargetName="DropDownBorder" Value="95"/>
				</Trigger>
				<Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true">
					<Setter Property="Margin" TargetName="Shdw" Value="0,0,5,5"/>
					<Setter Property="Color" TargetName="Shdw" Value="#71000000"/>
				</Trigger>
				<Trigger Property="IsEnabled" Value="false">
					<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
					<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
				</Trigger>
				<Trigger Property="IsGrouping" Value="true">
					<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
				</Trigger>
			</ControlTemplate.Triggers>
		</ControlTemplate>
		<Style x:Key="ComboBoxStyle1" TargetType="{x:Type ComboBox}">
			<Setter Property="FocusVisualStyle" Value="{StaticResource ComboBoxFocusVisual}"/>
			<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"/>
			<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
			<Setter Property="Margin" Value="0,0,0,0"/>
			<Setter Property="Padding" Value="2,1"/>
			<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
			<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
			<Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
			<Setter Property="VerticalContentAlignment" Value="Center"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type ComboBox}">
						<Border SnapsToDevicePixels="true" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
							<Grid>
								<Microsoft_Windows_Themes:ClassicBorderDecorator x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{x:Static Microsoft_Windows_Themes:ClassicBorderDecorator.ClassicBorderBrush}" BorderStyle="Sunken" BorderThickness="2">
									<Popup Focusable="False" AllowsTransparency="true" IsOpen="{TemplateBinding IsDropDownOpen}" Placement="Bottom" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" x:Name="PART_Popup">
										<Microsoft_Windows_Themes:SystemDropShadowChrome MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding Path=ActualWidth, ElementName=Border}" x:Name="Shdw" Color="Transparent">
											<Border x:Name="DropDownBorder" Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" BorderThickness="1">
												<ScrollViewer>
													<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" KeyboardNavigation.DirectionalNavigation="Contained"/>
												</ScrollViewer>
											</Border>
										</Microsoft_Windows_Themes:SystemDropShadowChrome>
									</Popup>
								</Microsoft_Windows_Themes:ClassicBorderDecorator>
								<DockPanel Margin="2">
									<FrameworkElement Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" DockPanel.Dock="Right"/>
									<Border Margin="{TemplateBinding Padding}" x:Name="SelectedItemBorder">
										<ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="1,1,1,1" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding SelectionBoxItem}" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"/>
									</Border>
								</DockPanel>
								<ToggleButton Focusable="false" Margin="2" MinHeight="0" MinWidth="0" Style="{StaticResource ComboBoxTransparentButtonStyle}" Width="Auto" ClickMode="Press" IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"/>
								<Grid>
									<!-- The ToggleButton is databound to the ComboBox itself to toggle IsDropDownOpen -->
									<ToggleButton Grid.Column="2" Template="{DynamicResource ComboBoxToggleButton}" x:Name="ToggleButton" Focusable="false" IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press"/>
									<ContentPresenter HorizontalAlignment="Left" Margin="3,3,23,3" x:Name="ContentSite" VerticalAlignment="Center" Content="{TemplateBinding SelectionBoxItem}" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" IsHitTestVisible="False"/>
						
									<!-- The TextBox must be named PART_EditableTextBox or ComboBox will not recognize it -->
									<TextBox Visibility="Hidden" Template="{DynamicResource ComboBoxTextBox}" HorizontalAlignment="Left" Margin="3,3,23,3" x:Name="PART_EditableTextBox" Style="{x:Null}" VerticalAlignment="Center" Focusable="True" Background="Transparent" IsReadOnly="{TemplateBinding IsReadOnly}" d:IsHidden="True"/>
						
									<!-- The Popup shows the list of items in the ComboBox. IsOpen is databound to IsDropDownOpen which is toggled via the ComboBoxToggleButton -->
									<Popup IsOpen="{TemplateBinding IsDropDownOpen}" Placement="Bottom" x:Name="Popup" Focusable="False" AllowsTransparency="True" PopupAnimation="Slide">
										<Grid MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{TemplateBinding ActualWidth}" x:Name="DropDown" SnapsToDevicePixels="True">
											<Border x:Name="DropDownBorder1" Background="{DynamicResource WindowBackgroundBrush}" BorderBrush="{DynamicResource SolidBorderBrush}" BorderThickness="1"/>
											<ScrollViewer Margin="4,6,4,6" Style="{DynamicResource SimpleScrollViewer}" SnapsToDevicePixels="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" CanContentScroll="True">
							
												<!-- The StackPanel is used to display the children by setting IsItemsHost to be True -->
												<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained"/>
								
											</ScrollViewer>
										</Grid>
									</Popup>
								</Grid>
							</Grid>
						</Border>
						<ControlTemplate.Triggers>
							<MultiTrigger>
								<MultiTrigger.Conditions>
									<Condition Property="IsSelectionBoxHighlighted" Value="true"/>
									<Condition Property="IsDropDownOpen" Value="false"/>
								</MultiTrigger.Conditions>
								<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
							</MultiTrigger>
							<Trigger Property="IsSelectionBoxHighlighted" Value="true">
								<Setter Property="Background" TargetName="SelectedItemBorder" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
							</Trigger>
							<Trigger Property="HasItems" Value="false">
								<Setter Property="MinHeight" TargetName="DropDownBorder" Value="95"/>
							</Trigger>
							<Trigger Property="IsEnabled" Value="false">
								<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
								<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
							</Trigger>
							<Trigger Property="IsGrouping" Value="true">
								<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
							</Trigger>
							<Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true">
								<Setter Property="Margin" TargetName="Shdw" Value="0,0,5,5"/>
								<Setter Property="Color" TargetName="Shdw" Value="#71000000"/>
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
			<Style.Triggers>
				<Trigger Property="IsEditable" Value="true">
					<Setter Property="IsTabStop" Value="false"/>
					<Setter Property="Padding" Value="1"/>
					<Setter Property="Template" Value="{StaticResource ComboBoxEditableTemplate}"/>
				</Trigger>
			</Style.Triggers>
		</Style>
	
		<!-- DefaultedBorderBrush is used to show KeyBoardFocus -->
		<LinearGradientBrush x:Key="DefaultedBorderBrush" EndPoint="0,1" StartPoint="0,0">
			<GradientStop Color="#777" Offset="0.0"/>
			<GradientStop Color="#000" Offset="1.0"/>
		</LinearGradientBrush>

		<SolidColorBrush x:Key="DisabledBackgroundBrush" Color="#EEE"/>
	
		<!-- MouseOverBrush is used for MouseOver in Button, Radio Button, CheckBox -->
		<LinearGradientBrush x:Key="MouseOverBrush" EndPoint="0,1" StartPoint="0,0">
			<GradientStop Color="#FFF" Offset="0.0"/>
			<GradientStop Color="#AAA" Offset="1.0"/>
		</LinearGradientBrush>
	
		<!-- PressedBrush is used for Pressed in Button, Radio Button, CheckBox -->
		<LinearGradientBrush x:Key="PressedBrush" EndPoint="0,1" StartPoint="0,0">
			<GradientStop Color="#BBB" Offset="0.0"/>
			<GradientStop Color="#EEE" Offset="0.1"/>
			<GradientStop Color="#EEE" Offset="0.9"/>
			<GradientStop Color="#FFF" Offset="1.0"/>
		</LinearGradientBrush>
		<SolidColorBrush x:Key="DisabledBorderBrush" Color="#AAA"/>	

		<!-- Disabled Brushes are used for the Disabled look of each control -->
		<SolidColorBrush x:Key="DisabledForegroundBrush" Color="#888"/>
	
		<!-- Simple ComboBox Toggle Button - This is used in ComboBox to expand and collapse the ComboBox Popup-->
		<ControlTemplate x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
			<Grid>
				<Grid.ColumnDefinitions>
					<ColumnDefinition/>
					<ColumnDefinition Width="20"/>
				</Grid.ColumnDefinitions>
				<Rectangle Grid.ColumnSpan="1" HorizontalAlignment="Stretch" x:Name="Rectangle" VerticalAlignment="Stretch" Width="Auto" Height="Auto" RadiusX="5" RadiusY="5" Fill="{DynamicResource DefaultedBorderBrush}" Stroke="{x:Null}" Opacity="0.5" Grid.Column="1"/>
				<Rectangle Grid.Column="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Height="Auto" RadiusX="5" RadiusY="5" Fill="{x:Null}" Stroke="{x:Null}"/>
				<Path Grid.Column="1" HorizontalAlignment="Center" x:Name="Arrow" VerticalAlignment="Center" Fill="{DynamicResource DisabledBackgroundBrush}" Data="M 0 0 L 4 4 L 8 0 Z"/>
			</Grid>
			<ControlTemplate.Triggers>
				<Trigger Property="IsMouseOver" Value="true">
					<Setter Property="Fill" Value="{DynamicResource MouseOverBrush}" TargetName="Rectangle"/>
				</Trigger>
				<Trigger Property="IsChecked" Value="true">
					<Setter Property="Fill" Value="{DynamicResource PressedBrush}" TargetName="Rectangle"/>
				</Trigger>
				<Trigger Property="IsEnabled" Value="False">
					<Setter Property="Fill" Value="{DynamicResource DisabledBackgroundBrush}" TargetName="Rectangle"/>
					<Setter Property="Stroke" Value="{DynamicResource DisabledBorderBrush}" TargetName="Rectangle"/>
					<Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
					<Setter Property="Fill" Value="{DynamicResource DisabledForegroundBrush}" TargetName="Arrow"/>
				</Trigger>
			</ControlTemplate.Triggers>
		</ControlTemplate>
	
		<!-- This is the area which contains the selected item in the ComboBox -->
	
		<ControlTemplate x:Key="ComboBoxTextBox" TargetType="{x:Type TextBox}">
			<!-- This must be named as PART_ContentHost -->
			<Border x:Name="PART_ContentHost" Focusable="False" Background="{TemplateBinding Background}"/>
		</ControlTemplate>

		<!-- Used for background of ScrollViewer, TreeView, ListBox, Expander, TextBox, Tab Control -->
		<SolidColorBrush x:Key="WindowBackgroundBrush" Color="#FFF"/>

		<SolidColorBrush x:Key="SolidBorderBrush" Color="#888"/>
	
		<!-- NormalBrush is used as the Background for SimpleButton, SimpleRepeatButton -->
		<LinearGradientBrush x:Key="NormalBrush" EndPoint="0,1" StartPoint="0,0">
			<GradientStop Color="#EEE" Offset="0.0"/>
			<GradientStop Color="#CCC" Offset="1.0"/>
		</LinearGradientBrush>
		<LinearGradientBrush x:Key="NormalBorderBrush" EndPoint="0,1" StartPoint="0,0">
			<GradientStop Color="#CCC" Offset="0.0"/>
			<GradientStop Color="#444" Offset="1.0"/>
		</LinearGradientBrush>
	
		<LinearGradientBrush x:Key="PressedBorderBrush" EndPoint="0,1" StartPoint="0,0">
			<GradientStop Color="#444" Offset="0.0"/>
			<GradientStop Color="#888" Offset="1.0"/>
		</LinearGradientBrush>
	
		<!-- Simple Repeat Button - This is used by Simple ScrollBar for the up and down buttons -->
		<Style x:Key="SimpleRepeatButton" d:IsControlPart="True" TargetType="{x:Type RepeatButton}" BasedOn="{x:Null}">
			<Setter Property="Background" Value="{DynamicResource NormalBrush}"/>
			<Setter Property="BorderBrush" Value="{DynamicResource NormalBorderBrush}"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type RepeatButton}">
						<Grid>
							<Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"/>
							<ContentPresenter HorizontalAlignment="Center" x:Name="ContentPresenter" VerticalAlignment="Center" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"/>
						</Grid>
						<ControlTemplate.Triggers>
							<Trigger Property="IsKeyboardFocused" Value="true">
								<Setter Property="BorderBrush" Value="{DynamicResource DefaultedBorderBrush}" TargetName="Border"/>
							</Trigger>
							<Trigger Property="IsMouseOver" Value="true">
								<Setter Property="Background" Value="{DynamicResource MouseOverBrush}" TargetName="Border"/>
							</Trigger>
							<Trigger Property="IsPressed" Value="true">
								<Setter Property="Background" Value="{DynamicResource PressedBrush}" TargetName="Border"/>
								<Setter Property="BorderBrush" Value="{DynamicResource PressedBorderBrush}" TargetName="Border"/>
							</Trigger>
							<Trigger Property="IsEnabled" Value="false">
								<Setter Property="Background" Value="{DynamicResource DisabledBackgroundBrush}" TargetName="Border"/>
								<Setter Property="BorderBrush" Value="{DynamicResource DisabledBorderBrush}" TargetName="Border"/>
								<Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
	
		<!-- Simple ScrollRepeatButton Style - This RepeatButton is used above and below the Thumb in the Scrollbar. They are set to transparent si that they do not show over the scrollbar -->
		<Style x:Key="SimpleScrollRepeatButtonStyle" d:IsControlPart="True" TargetType="{x:Type RepeatButton}">
			<Setter Property="Background" Value="Transparent"/>
			<Setter Property="BorderBrush" Value="Transparent"/>
			<Setter Property="IsTabStop" Value="false"/>
			<Setter Property="Focusable" Value="false"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type RepeatButton}">
						<Grid>
							<Rectangle StrokeThickness="{TemplateBinding BorderThickness}"/>
						</Grid>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
	
		<!-- Simple Thumb - The Thumb is the draggable part of the Scrollbar -->
		<Style x:Key="SimpleThumbStyle" d:IsControlPart="True" TargetType="{x:Type Thumb}" BasedOn="{x:Null}">
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type Thumb}">
						<Grid Margin="0,0,0,0" x:Name="Grid">
							<Rectangle HorizontalAlignment="Stretch" x:Name="Rectangle" VerticalAlignment="Stretch" Width="Auto" Height="Auto" RadiusX="2" RadiusY="2" Fill="{DynamicResource NormalBrush}" Stroke="{DynamicResource NormalBorderBrush}"/>
						</Grid>
						<ControlTemplate.Triggers>
							<Trigger Property="IsFocused" Value="True"/>
							<Trigger Property="IsMouseOver" Value="True"/>
							<Trigger Property="IsEnabled" Value="False"/>
							<Trigger Property="IsDragging" Value="True"/>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
	
		<!-- Simple ScrollBar  This makes use of SimpleThumb, SimpleRepeatButton and SimpleScrollRepeatButton -->
	
		<Style x:Key="SimpleScrollBar" TargetType="{x:Type ScrollBar}">
			<Setter Property="Stylus.IsFlicksEnabled" Value="false"/>
			<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type ScrollBar}">
						<Grid x:Name="GridRoot" Width="7.475">
							<Grid.RowDefinitions>
								<RowDefinition MaxHeight="18" Height="0.144*"/>
								<RowDefinition Height="0.712*"/>
								<RowDefinition MaxHeight="18" Height="0.144*"/>
							</Grid.RowDefinitions>
						
							<RepeatButton x:Name="DecreaseRepeat" Style="{DynamicResource SimpleRepeatButton}" Command="ScrollBar.LineUpCommand">
								<RepeatButton.Background>
									<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
										<GradientStop Color="#FF444444" Offset="0"/>
										<GradientStop Color="#FFCCCCCC" Offset="1"/>
									</LinearGradientBrush>
								</RepeatButton.Background>
								<Grid/>
							</RepeatButton>
						
							<!-- Track is a special layout container which sizes the thumb and the repeat button which do jump scrolling either side of it -->
							<Track Grid.Row="1" x:Name="PART_Track" Orientation="Vertical" IsDirectionReversed="true">
								<Track.Thumb>
									<Thumb Style="{DynamicResource SimpleThumbStyle}" Cursor="Hand"/>
								</Track.Thumb>
								<Track.IncreaseRepeatButton>
									<RepeatButton x:Name="PageUp" Style="{DynamicResource SimpleScrollRepeatButtonStyle}" Command="ScrollBar.PageDownCommand" Background="{x:Null}" BorderBrush="{x:Null}"/>
								</Track.IncreaseRepeatButton>
								<Track.DecreaseRepeatButton>
									<RepeatButton x:Name="PageDown" Style="{DynamicResource SimpleScrollRepeatButtonStyle}" Command="ScrollBar.PageUpCommand" Background="{x:Null}" BorderBrush="{x:Null}"/>
								</Track.DecreaseRepeatButton>
							</Track>
						
							<RepeatButton Grid.Row="2" x:Name="IncreaseRepeat" Style="{DynamicResource SimpleRepeatButton}" Command="ScrollBar.LineDownCommand">
								<RepeatButton.Background>
									<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
										<GradientStop Color="#FFEEEEEE" Offset="0"/>
										<GradientStop Color="#FF444444" Offset="1"/>
									</LinearGradientBrush>
								</RepeatButton.Background>
								<Grid/>
							</RepeatButton>
						</Grid>
					
						<!-- This uses a single template for ScrollBar and rotate it to be Horizontal
					It also changes the commands so that the it does Left and Right instead of Up and Down Commands -->
						<ControlTemplate.Triggers>
							<Trigger Property="Orientation" Value="Horizontal">

								<!-- Rotate the ScrollBar from Vertical to Horizontal -->
								<Setter Property="LayoutTransform" TargetName="GridRoot">
									<Setter.Value>
										<RotateTransform Angle="-90"/>
									</Setter.Value>
								</Setter>
							
								<!-- Track is bound to Orientation internally, so we need to rotate it back to Vertical -->
								<Setter TargetName="PART_Track" Property="Orientation" Value="Vertical"/>
					
								<!-- Change the commands to do Horizontal commands -->
								<Setter Property="Command" Value="ScrollBar.LineLeftCommand" TargetName="DecreaseRepeat"/>
								<Setter Property="Command" Value="ScrollBar.LineRightCommand" TargetName="IncreaseRepeat"/>
								<Setter Property="Command" Value="ScrollBar.PageLeftCommand" TargetName="PageDown"/>
								<Setter Property="Command" Value="ScrollBar.PageRightCommand" TargetName="PageUp"/>
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
	
		<!-- Simple ScrollViewer 
	ScrollViewer is a Grid control which has a ContentPresenter and a Horizontal and Vertical ScrollBar 
	It is used by ListBox, MenuItem, ComboBox, and TreeView -->
		<Style x:Key="SimpleScrollViewer" TargetType="{x:Type ScrollViewer}" BasedOn="{x:Null}">
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type ScrollViewer}">
						<Grid Background="{TemplateBinding Background}">
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="*"/>
								<ColumnDefinition Width="Auto"/>
							</Grid.ColumnDefinitions>
							<Grid.RowDefinitions>
								<RowDefinition Height="*"/>
								<RowDefinition Height="Auto"/>
							</Grid.RowDefinitions>
							<ScrollContentPresenter Grid.Column="0" Grid.Row="0" Margin="{TemplateBinding Padding}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" CanContentScroll="{TemplateBinding CanContentScroll}"/>
						
							<!-- The visibility of the ScrollBars is controlled by the implementation fo the control -->
							<ScrollBar Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Grid.Column="0" Grid.Row="1" x:Name="PART_HorizontalScrollBar" Style="{DynamicResource SimpleScrollBar}" Orientation="Horizontal" Value="{Binding Path=HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportWidth}" Minimum="0" Maximum="{TemplateBinding ScrollableWidth}" AutomationProperties.AutomationId="HorizontalScrollBar"/>
							<ScrollBar Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Grid.Column="1" Grid.Row="0" x:Name="PART_VerticalScrollBar" Style="{DynamicResource SimpleScrollBar}" Orientation="Vertical" Value="{Binding Path=VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}" Minimum="0" Maximum="{TemplateBinding ScrollableHeight}" AutomationProperties.AutomationId="VerticalScrollBar"/>
						</Grid>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
	
		<!-- Simple ComboBox 
	This uses the ComboBoxToggleButton to expand and collapse a Popup control
	SimpleScrollViewer to allow items to be scrolled and SimpleComboBoxItem to define the look of each item 
	The Popup shows a list of items in a StackPanel-->
	
		<Style x:Key="SimpleComboBox" TargetType="{x:Type ComboBox}">
			<Setter Property="SnapsToDevicePixels" Value="true"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type ComboBox}">
						<Grid>
							<!-- The ToggleButton is databound to the ComboBox itself to toggle IsDropDownOpen -->
							<ToggleButton Grid.Column="2" Template="{DynamicResource ComboBoxToggleButton}" x:Name="ToggleButton" Focusable="false" IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press"/>
							<ContentPresenter HorizontalAlignment="Left" Margin="3,3,23,3" x:Name="ContentSite" VerticalAlignment="Center" Content="{TemplateBinding SelectionBoxItem}" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" IsHitTestVisible="False"/>
						
							<!-- The TextBox must be named PART_EditableTextBox or ComboBox will not recognize it -->
							<TextBox Visibility="Hidden" Template="{DynamicResource ComboBoxTextBox}" HorizontalAlignment="Left" Margin="3,3,23,3" x:Name="PART_EditableTextBox" Style="{x:Null}" VerticalAlignment="Center" Focusable="True" Background="Transparent" IsReadOnly="{TemplateBinding IsReadOnly}" d:IsHidden="True"/>
						
							<!-- The Popup shows the list of items in the ComboBox. IsOpen is databound to IsDropDownOpen which is toggled via the ComboBoxToggleButton -->
							<Popup IsOpen="{TemplateBinding IsDropDownOpen}" Placement="Bottom" x:Name="Popup" Focusable="False" AllowsTransparency="True" PopupAnimation="Slide">
								<Grid MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{TemplateBinding ActualWidth}" x:Name="DropDown" SnapsToDevicePixels="True">
									<Border x:Name="DropDownBorder" Background="{DynamicResource WindowBackgroundBrush}" BorderBrush="{DynamicResource SolidBorderBrush}" BorderThickness="1" Margin="0,0,0,-75.792"/>
									<ScrollViewer Margin="4,6,4,-71.792" Style="{DynamicResource SimpleScrollViewer}" SnapsToDevicePixels="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" CanContentScroll="True">
							
										<!-- The StackPanel is used to display the children by setting IsItemsHost to be True -->
										<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained"/>
								
									</ScrollViewer>
								</Grid>
							</Popup>
						</Grid>
						<ControlTemplate.Triggers>						
							<!-- This forces the DropDown to have a minimum size if it is empty -->
							<Trigger Property="HasItems" Value="false">
								<Setter Property="MinHeight" Value="95" TargetName="DropDownBorder"/>
							</Trigger>
							<Trigger Property="IsEnabled" Value="false">
								<Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
							</Trigger>
							<Trigger Property="IsGrouping" Value="true">
								<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
							</Trigger>
							<Trigger Property="AllowsTransparency" SourceName="Popup" Value="true">
								<Setter Property="CornerRadius" Value="4" TargetName="DropDownBorder"/>
								<Setter Property="Margin" Value="0,2,0,0" TargetName="DropDownBorder"/>
							</Trigger>
							<Trigger Property="IsEditable" Value="true">
								<Setter Property="IsTabStop" Value="false"/>
								<Setter Property="Visibility" Value="Visible" TargetName="PART_EditableTextBox"/>
								<Setter Property="Visibility" Value="Hidden" TargetName="ContentSite"/>
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
	
		<ItemsPanelTemplate x:Key="ItemsPanelTemplate1">
			<StackPanel IsItemsHost="True"/>
		</ItemsPanelTemplate>
		<Style x:Key="ButtonFocusVisual">
			<Setter Property="Control.Template">
				<Setter.Value>
					<ControlTemplate>
						<Border>
							<Rectangle SnapsToDevicePixels="true" Stroke="Black" StrokeDashArray="1 2" StrokeThickness="1" Margin="4"/>
						</Border>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		<Style x:Key="ButtonStyle1" TargetType="{x:Type Button}">
			<Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
			<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
			<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
			<Setter Property="BorderBrush" Value="{x:Static Microsoft_Windows_Themes:ClassicBorderDecorator.ClassicBorderBrush}"/>
			<Setter Property="BorderThickness" Value="3"/>
			<Setter Property="HorizontalContentAlignment" Value="Center"/>
			<Setter Property="VerticalContentAlignment" Value="Center"/>
			<Setter Property="Padding" Value="0,0,1,1"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type Button}">
						<Microsoft_Windows_Themes:ClassicBorderDecorator SnapsToDevicePixels="true" x:Name="ContentContainer" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderStyle="Raised" BorderThickness="3">
							<ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>
						</Microsoft_Windows_Themes:ClassicBorderDecorator>
						<ControlTemplate.Triggers>
							<Trigger Property="IsKeyboardFocused" Value="true">
								<Setter Property="BorderStyle" TargetName="ContentContainer" Value="RaisedFocused"/>
							</Trigger>
							<Trigger Property="IsDefaulted" Value="true">
								<Setter Property="BorderStyle" TargetName="ContentContainer" Value="RaisedFocused"/>
							</Trigger>
							<Trigger Property="IsPressed" Value="true">
								<Setter Property="BorderStyle" TargetName="ContentContainer" Value="RaisedPressed"/>
							</Trigger>
							<Trigger Property="ToggleButton.IsChecked" Value="true">
								<Setter Property="BorderStyle" TargetName="ContentContainer" Value="RaisedPressed"/>
							</Trigger>
							<Trigger Property="IsEnabled" Value="false">
								<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
	
		<!-- Simple ComboBox Toggle Button - This is used in ComboBox to expand and collapse the ComboBox Popup-->
		<ControlTemplate x:Key="ComboBoxToggleButton2" TargetType="{x:Type ToggleButton}">
			<Grid>
				<Grid.ColumnDefinitions>
					<ColumnDefinition/>
					<ColumnDefinition Width="20"/>
				</Grid.ColumnDefinitions>
				<Rectangle Grid.ColumnSpan="2" HorizontalAlignment="Stretch" x:Name="Rectangle" VerticalAlignment="Stretch" Width="Auto" Height="Auto" RadiusX="5" RadiusY="5" Stroke="{x:Null}" Opacity="1" TextElement.Foreground="#FFFFFFFF">
					<Rectangle.Fill>
						<LinearGradientBrush EndPoint="-0.004,0.754" StartPoint="-0.004,-0.246">
							<GradientStop Color="#FF777777" Offset="0"/>
							<GradientStop Color="#FF000000" Offset="1"/>
						</LinearGradientBrush>
					</Rectangle.Fill>
				</Rectangle>
				<Rectangle Grid.Column="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Height="Auto" RadiusX="5" RadiusY="5" Fill="{x:Null}" Stroke="{x:Null}"/>
				<Path Grid.Column="1" HorizontalAlignment="Center" x:Name="Arrow" VerticalAlignment="Center" Fill="{DynamicResource DisabledBackgroundBrush}" Data="M 0 0 L 4 4 L 8 0 Z"/>
			</Grid>
			<ControlTemplate.Triggers>
				<Trigger Property="IsMouseOver" Value="true">
					<Setter Property="Fill" Value="{DynamicResource MouseOverBrush}" TargetName="Rectangle"/>
				</Trigger>
				<Trigger Property="IsChecked" Value="true">
					<Setter Property="Fill" Value="{DynamicResource PressedBrush}" TargetName="Rectangle"/>
				</Trigger>
				<Trigger Property="IsEnabled" Value="False">
					<Setter Property="Fill" Value="{DynamicResource DisabledBackgroundBrush}" TargetName="Rectangle"/>
					<Setter Property="Stroke" Value="{DynamicResource DisabledBorderBrush}" TargetName="Rectangle"/>
					<Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
					<Setter Property="Fill" Value="{DynamicResource DisabledForegroundBrush}" TargetName="Arrow"/>
				</Trigger>
			</ControlTemplate.Triggers>
		</ControlTemplate>
	
		<!-- Simple ComboBox 
	This uses the ComboBoxToggleButton to expand and collapse a Popup control
	SimpleScrollViewer to allow items to be scrolled and SimpleComboBoxItem to define the look of each item 
	The Popup shows a list of items in a StackPanel-->
	
		<Style x:Key="SimpleComboBox2" TargetType="{x:Type ComboBox}">
			<Setter Property="SnapsToDevicePixels" Value="true"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type ComboBox}">
						<Grid>
							<!-- The ToggleButton is databound to the ComboBox itself to toggle IsDropDownOpen -->
							<ToggleButton Grid.Column="0" Template="{DynamicResource ComboBoxToggleButton}" x:Name="ToggleButton" Focusable="false" IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press" d:LayoutOverrides="GridBox" HorizontalAlignment="Right" Width="24"/>
						
							<!-- The Popup shows the list of items in the ComboBox. IsOpen is databound to IsDropDownOpen which is toggled via the ComboBoxToggleButton -->
							<Popup IsOpen="{TemplateBinding IsDropDownOpen}" Placement="Bottom" x:Name="Popup" Focusable="False" AllowsTransparency="True" PopupAnimation="Slide">
								<Grid MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{TemplateBinding ActualWidth}" x:Name="DropDown" SnapsToDevicePixels="True">
									<Border x:Name="DropDownBorder" Background="{DynamicResource WindowBackgroundBrush}" BorderBrush="{DynamicResource SolidBorderBrush}" BorderThickness="1"/>
									<ScrollViewer Margin="4,6,4,6" Style="{DynamicResource SimpleScrollViewer}" SnapsToDevicePixels="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" CanContentScroll="True">
							
										<!-- The StackPanel is used to display the children by setting IsItemsHost to be True -->
										<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" Height="Auto" MaxHeight="600" />
								
									</ScrollViewer>
								</Grid>
							</Popup>
						</Grid>
						<ControlTemplate.Triggers>						
							<Trigger Property="MaxDropDownHeight" Value="256"/>						
							<!-- This forces the DropDown to have a minimum size if it is empty -->
							<Trigger Property="HasItems" Value="false">
								<Setter Property="MinHeight" Value="95" TargetName="DropDownBorder"/>
							</Trigger>
							<Trigger Property="IsEnabled" Value="false">
								<Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
							</Trigger>
							<Trigger Property="IsGrouping" Value="true">
								<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
							</Trigger>
							<Trigger Property="AllowsTransparency" SourceName="Popup" Value="true">
								<Setter Property="CornerRadius" Value="4" TargetName="DropDownBorder"/>
								<Setter Property="Margin" Value="0,2,0,0" TargetName="DropDownBorder"/>
							</Trigger>
							<Trigger Property="IsEditable" Value="true">
								<Setter Property="IsTabStop" Value="false"/>
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
	
	</UserControl.Resources>
    
    <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
        <StackPanel Width="Auto" HorizontalAlignment="Stretch" Background="LightCoral" Name="stBuddyPanel" />
    </ScrollViewer>

</UserControl>
